* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  width: 480px;
  min-height: 480px;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC',
    sans-serif;
  background: #fafafa;
  color: #1d1d1f;
  font-size: 13px;
}

.header {
  padding: 20px 18px 18px;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: start;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: white;
  background: linear-gradient(135deg, #6b7cff 0%, #8b9aff 100%);
  display: inline-block;
  padding: 2px 11px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.header p {
  font-size: 12px;
  color: #8e8e93;
  font-weight: 400;
  margin-left: 2px;
}

.btn-open-tab {
  padding: 6px 12px;
  background: white;
  color: #6b7cff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-open-tab:hover {
  background: #f5f5f7;
  border-color: #6b7cff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(107, 124, 255, 0.15);
}

.btn-open-tab:active {
  transform: translateY(0);
}

.container {
  padding: 0 14px 14px;
}

.card {
  background: white;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid #e8e8e8;
}

.input-group {
  margin-bottom: 10px;
}

.input-group:last-of-type {
  margin-bottom: 12px;
}

.input-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #8e8e93;
  margin-bottom: 5px;
}

/* URL 输入行 */
.url-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.match-mode-select {
  width: 85px;
  flex-shrink: 0;
  border: 1px solid #e0e0e0;
  border-radius: 7px;
  padding: 8px 6px;
  font-size: 12px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.2s;
}

.match-mode-select:hover {
  border-color: #6b7cff;
}

.match-mode-select:focus {
  outline: none;
  border-color: #6b7cff;
  box-shadow: 0 0 0 3px rgba(107, 124, 255, 0.1);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #e0e0e0;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  background: white;
  color: #1d1d1f;
  transition: all 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #6b7cff;
  box-shadow: 0 0 0 3px rgba(107, 124, 255, 0.1);
}

textarea {
  min-height: 80px;
  resize: vertical;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.btn-group {
  display: flex;
  gap: 8px;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 9px 0;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #6b7cff 0%, #8b9aff 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(107, 124, 255, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #f5f5f7;
  color: #1d1d1f;
}

.btn-secondary:hover {
  background: #e8e8ea;
}

.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 8px;
}

.rules-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
}

.rules-count {
  font-size: 11px;
  color: #8e8e93;
  background: #f5f5f7;
  padding: 2px 8px;
  border-radius: 10px;
}

#rules {
  max-height: 300px;
  overflow-y: auto;
}

.rule-item {
  background: white;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

/*  添加禁用状态样式 */
.rule-item.disabled {
  opacity: 0.5;
}

.rule-item:hover {
  border-color: #6b7cff;
  box-shadow: 0 2px 8px rgba(107, 124, 255, 0.1);
}

.rule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.rule-url {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #1d1d1f;
  flex: 1;
  min-width: 0;
}

.rule-url span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.method-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.method-all {
  background: #e0e7ff;
  color: #4338ca;
}

.method-get {
  background: #d1fae5;
  color: #065f46;
}

.method-post {
  background: #fef3c7;
  color: #92400e;
}

.method-put {
  background: #dbeafe;
  color: #1e40af;
}

.method-delete {
  background: #fee2e2;
  color: #991b1b;
}

.match-mode-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  flex-shrink: 0;
}

.match-mode-contains {
  background: #f3f4f6;
  color: #6b7280;
}

.match-mode-exact {
  background: #e0e7ff;
  color: #4338ca;
}



/* 新的开关样式 */
.rule-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 隐藏 checkbox */
.rule-toggle-checkbox {
  display: none;
}

.toggleSwitch {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 36px;
  /* 从 50px 改为 36px */
  height: 20px;
  /* 从 30px 改为 20px */
  background-color: rgb(82, 82, 82);
  border-radius: 20px;
  cursor: pointer;
  transition-duration: .2s;
  flex-shrink: 0;
}

.toggleSwitch::after {
  content: "";
  position: absolute;
  height: 6px;
  /* 从 10px 改为 6px */
  width: 6px;
  /* 从 10px 改为 6px */
  left: 4px;
  /* 从 5px 改为 4px */
  background-color: transparent;
  border-radius: 50%;
  transition-duration: .2s;
  box-shadow: 3px 1px 5px rgba(8, 8, 8, 0.26);
  /* 调整阴影 */
  border: 4px solid white;
  /* 从 5px 改为 4px */
}

.rule-toggle-checkbox:checked+.toggleSwitch::after {
  transform: translateX(100%);
  transition-duration: .2s;
  background-color: white;
}

/* Switch background change */
.rule-toggle-checkbox:checked+.toggleSwitch {
  background-color: rgb(148, 118, 255);
  transition-duration: .2s;
}

/* 禁用状态时的开关样式 */
.disabled .toggleSwitch {
  opacity: 0.6;
}

.btn-delete {
  padding: 4px 10px;
  background: #fee2e2;
  color: #991b1b;
  border: none;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-delete:hover {
  background: #fecaca;
  transform: translateY(-1px);
}

.btn-delete:active {
  transform: translateY(0);
}

.rule-data {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 11px;
  color: #6b7280;
  background: #f9fafb;
  padding: 6px 8px;
  border-radius: 5px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #8e8e93;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 13px;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 10000;
  animation: fadeInOut 1.5s ease-in-out;
}

@keyframes fadeInOut {

  0%,
  100% {
    opacity: 0;
  }

  10%,
  90% {
    opacity: 1;
  }
}

/* 折叠展开相关样式 */
.rule-data-wrapper {
  position: relative;
}

.rule-data {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 11px;
  color: #6b7280;
  background: #f9fafb;
  padding: 6px 8px;
  border-radius: 5px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 60px;
  transition: max-height 0.3s ease;
}

.rule-data.expanded {
  max-height: none;
}

.btn-toggle-data {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 4px 8px;
  background: #f5f5f7;
  color: #6b7280;
  border: none;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-data:hover {
  background: #e8e8ea;
  color: #1d1d1f;
}

.btn-toggle-data svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s;
}

.btn-toggle-data.expanded svg {
  transform: rotate(180deg);
}

/* 渐变遮罩效果 */
.rule-data:not(.expanded)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, transparent, #f9fafb);
  pointer-events: none;
}